package com.yaosheng.thread.thread;

import java.util.concurrent.TimeUnit;

/**
 * Created by yaosheng on 2021/7/2.
 */
public class TestThreadLocal {

    volatile static Person person = new Person ();

    public static void main(String[] args) {

        new Thread ( () -> {
            try{
                TimeUnit.SECONDS.sleep (2);
            } catch (InterruptedException e) {
                e.printStackTrace ();
            }
            System.out.println (person.name);
        }).start ();

        new Thread ( () -> {
            try{
                TimeUnit.SECONDS.sleep (1);
            } catch (InterruptedException e) {
                e.printStackTrace ();
            }
            person.name = "刘新盼";
            System.out.println (person.name);
        }).start ();
    }

    static class Person {
        String name = "姚圣";
    }
}
